#README: advanced version of pic grabber, works through atomic2, modify board= to your need,
#        this modified version searches board=$1 for attachments and downthemall in diff incrementals
board=$1

boardurlprefix="http://www.newsmth.net/bbsbfind.php?q=1&board="
boardurlsurfix="&dt=1&ag=on&og="
#delay time=1day, attachment=on, 'og=' means lz & re post / 'og=on' means lz post only
boardurl=$boardurlprefix$board$boardurlsurfix

/usr/local/bin/wget -O board.htm --no-cache $boardurl

posthttpaddrprefix="s/httpprefix/http:\/\/www\.newsmth\.net\/atomic2\.php\?act=article\&board="
#act=article is fixed; board= PICTUR*/PIELOV*/MYPHOT*, etc need adjust to your needs from $board=$1
posthttpaddrsurfix="\&id=/g"
posthttpaddr=$posthttpaddrprefix$board$posthttpaddrsurfix

#diff setting
touch posturl.list
mv posturl.list posturl_old.list
#diff setting

cat board.htm |grep bbsqry | sed  -e "s/.*&id=/httpprefix/g" | sed  -e "s/\">.*//g" > posturl.list
rm -f board.htm

sed -i -e "$posthttpaddr" posturl.list
#if put $posthttpaddr, i.e. without "$..", crond hangs here... refusing to do the httpprefix replacement, so "$posthttpaddr" is added

#diff setting
diff posturl.list posturl_old.list | grep "<" | sed -e "s/< //g"
diff posturl.list posturl_old.list | grep "<" | sed -e "s/< //g" > posturl_diff.list
#diff setting

/usr/local/bin/wget -O postall.htm -i posturl_diff.list
# can get all list files and sum-up all html into one big file postall.htm
rm -f posturl.list-*

#for freebsd, use gsed instead of sed will work!! here use tr -s for linux-freebsd compatible
cat postall.htm | tr -s "<li>" "\n" | grep "att\.php" |sed -e "s/.*att\.php/http:\/\/www\.newsmth\.net\/att\.php/g" | sed -e "s/' target=.*//g" > picurl.list
#cat postall.htm | sed -e "s/<li>/\n/g" | grep "att\.php" |sed -e "s/.*att\.php/http:\/\/www\.newsmth\.net\/att\.php/g" | sed -e "s/' target='_blank'.*//g" > picurl.list

# can get all pic file url into picurl.list
rm -f postall.htm

/usr/local/bin/wget -r -nd -A jpg --no-dns-cache -i picurl.list

renamestrprefix="s/att\.php\?n\.[0-9]*\./"
renamestrsurfix="\_/g"
renamestr=$renamestrprefix$board$renamestrsurfix

./rename.pl -f $renamestr att*jpg
#need to rename att.php?boardid.postid.attachmentid.jpg file name...
rm -f picurl.list

#mogrify -resize 640x480 *.jpg
#make it universal size

